import request from '@/config/axios'

// 物料类别 VO
export interface ProductCategoryVO {
  id: number // 编号
  parentId: number // 父id
  description: string // 产品描述
}

// 物料类别 API
export const ProductCategoryApi = {
  // 查询物料类别分页
  getProductCategoryPage: async (params: any) => {
    return await request.get({ url: `/manu/product-category/page`, params })
  },
    // 查询物料类别列表
    getProductCategoryList: async (params) => {
      return await request.get({ url: `/manu/product-category/list`, params })
    },

  // 查询物料类别详情
  getProductCategory: async (id: number) => {
    return await request.get({ url: `/manu/product-category/get?id=` + id })
  },

  // 新增物料类别
  createProductCategory: async (data: ProductCategoryVO) => {
    return await request.post({ url: `/manu/product-category/create`, data })
  },

  // 修改物料类别
  updateProductCategory: async (data: ProductCategoryVO) => {
    return await request.put({ url: `/manu/product-category/update`, data })
  },

  // 删除物料类别
  deleteProductCategory: async (id: number) => {
    return await request.delete({ url: `/manu/product-category/delete?id=` + id })
  },

  // 导出物料类别 Excel
  exportProductCategory: async (params) => {
    return await request.download({ url: `/manu/product-category/export-excel`, params })
  },

// ==================== 子表（物料特征模板） ====================

  // 获得物料特征模板分页
  getProductCharacterTemplatePage: async (params) => {
    return await request.get({ url: `/manu/product-category/product-character-template/page`, params })
  },
  // 新增物料特征模板
  createProductCharacterTemplate: async (data) => {
    console.log(data)
    return await request.post({ url: `/manu/product-category/product-character-template/create`, data })
  },

  // 修改物料特征模板
  updateProductCharacterTemplate: async (data) => {
    return await request.put({ url: `/manu/product-category/product-character-template/update`, data })
  },

  // 删除物料特征模板
  deleteProductCharacterTemplate: async (id: number) => {
    return await request.delete({ url: `/manu/product-category/product-character-template/delete?id=` + id })
  },

  // 获得物料特征模板
  getProductCharacterTemplate: async (id: number) => {
    return await request.get({ url: `/manu/product-category/product-character-template/get?id=` + id })
  },

// ==================== 子表（物料主数据） ====================

  // 获得物料主数据分页
  getProductMasterPage: async (params) => {
    return await request.get({ url: `/manu/product-category/product-master/page`, params })
  },
  // 新增物料主数据
  createProductMaster: async (data) => {
    return await request.post({ url: `/manu/product-category/product-master/create`, data })
  },

  // 修改物料主数据
  updateProductMaster: async (data) => {
    return await request.put({ url: `/manu/product-category/product-master/update`, data })
  },

  // 删除物料主数据
  deleteProductMaster: async (id: number) => {
    return await request.delete({ url: `/manu/product-category/product-master/delete?id=` + id })
  },

  // 获得物料主数据
  getProductMaster: async (id: number) => {
    return await request.get({ url: `/manu/product-category/product-master/get?id=` + id })
  },
}
